import React from 'react'
import App from './App'
import {BrowserRouter,Route,Switch} from 'react-router-dom'
import storeFun from './utils/store'
import Admin from './admin'
import Common from './common'
import Home from './pages/home'
import Test from './pages/test'
import Login from './pages/login'
import Xmj from './pages/修毛胶机'
import Order from './pages/order'
// // import Page404 from './pages/404'
// import LoginForm from './pages/form/login'
// import Button from './pages/ui/button'
// import BasicTable from './pages/ui/table/basicTable'
// import User from './pages/rbac/user'
// import Role from './pages/rbac/role'
// import Menu from './pages/rbac/menu'
// import Transfers from './pages/ui/transfer'
// import TreeSelects from './pages/ui/treeSelect'
// import Trees from './pages/ui/tree'

class Router extends React.Component{


    componentDidMount(){
        if (this.props.token===''&& storeFun.getStorage() ){
            console.log('token:'+this.props.token)

            console.log(this.props.history)

        }else {

        }
    }

    render(){

        return (
            <BrowserRouter>
                <App>
                    <Switch>
                        <Route path="/login"  component={Login}/>
                        {/* 一个括号引发的惨案 */}
                        {/*<Route path="/common" render={()=>{*/}
                            {/*<Common>*/}
                                {/*<Route path="/common/info" component={Order}/>*/}
                            {/*</Common>*/}
                        {/*}}/>*/}
                        <Route path="/common" render={()=>
                            <Common>
                                <Route path="/common/info" component={Xmj}/>
                            </Common>
                        }/>
                        <Route path="/" render={() =>
                            <Admin>
                                <Switch>
                                    <Route path="/admin/home" component={Home} />
                                    <Route path="/admin/test" component={Test} />
                                    {/*<Route path="/admin/form/login" component={LoginForm}/>*/}
                                    {/*<Route path="/admin/ui/buttions" component={Button}/>*/}
                                    {/*<Route path="/admin/table/basic" component={BasicTable}/>*/}
                                    {/*<Route path="/admin/upms/user" component={User}/>*/}
                                    {/*<Route path="/admin/upms/role" component={Role}/>*/}
                                    {/*<Route path="/admin/upms/menu" component={Menu}/>*/}
                                    {/*<Route path="/admin/ui/transfer" component={Transfers}/>*/}
                                    {/*<Route path="/admin/ui/treeSelect" component={TreeSelects}/>*/}
                                    {/*<Route path="/admin/ui/tree" component={Trees}/>*/}
                                    <Route component={Home} />
                                    {/*<Route  component={Page404}/>*/}
                                </Switch>
                            </Admin>
                        }/>
                    </Switch>
                </App>
            </BrowserRouter>
        )
    }
}

export default Router